CREATE PROCEDURE [dbo].[GetPTOUsedByUserID](@userID int,@startDate datetime,@enddate datetime )
AS
declare @PTOHours int
declare @RolledPTOHours int
	select @PTOHours = sum(duration) from EntryLog
	where UserID = @userID and EntryDate  between @startDate and @endDate and CategoryID in (4,7,13) 
	
	select @RolledPTOHours = PTOHoursRolledIntoCurrentYear from dbo.Users
	where UserID=@userID
	--select @PTOHours
	--select @RolledPTOHours
	select coalesce(@PTOHours,0) - coalesce(@RolledPTOHours ,0)
RETURN

